
		function isNumberKey(evt){
			var charCode=(evt.which)?evt.which: event.keyCode;
			if(charCode>31&&(charCode<48||charCode>57)){
				return false;
			}
			
			return true;
		}
		
        function validatefName(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("fname").value)){
                // Style green
                document.getElementById("fname").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("fname" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("fname").style.background ='#e35152';
                // Show error prompt
                document.getElementById("fname" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
		  function validatemName(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("mname").value)){
                // Style green
                document.getElementById("mname").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("mname" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("mname").style.background ='#e35152';
                // Show error prompt
                document.getElementById("mname" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
		  function validatelName(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("lname").value)){
                // Style green
                document.getElementById("lname").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("lname" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("lname").style.background ='#e35152';
                // Show error prompt
                document.getElementById("lname" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
		function validateuserName(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("username").value)){
                // Style green
                document.getElementById("username").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("username" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("username").style.background ='#e35152';
                // Show error prompt
                document.getElementById("username" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatepassword(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("password").value)&&document.getElementById("password").value.length>=8){
                // Style green
                document.getElementById("password").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("password" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("password").style.background ='#e35152';
                // Show error prompt
                document.getElementById("password" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validaterpassword(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("rpassword").value) && document.getElementById("rpassword").value == document.getElementById("password").value){
                // Style green
                document.getElementById("rpassword").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("rpassword" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("rpassword").style.background ='#e35152';
                // Show error prompt
                document.getElementById("rpassword" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatecardnumber(){
            // Validation rule
            var re = /[0-9]$/;
            // Check input
            if(re.test(document.getElementById("cardnumber").value)){
                // Style green
                document.getElementById("cardnumber").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("cardnumber" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("cardnumber").style.background ='#e35152';
                // Show error prompt
                document.getElementById("cardnumber" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validateccfName(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("ccfname").value)){
                // Style green
                document.getElementById("ccfname").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("ccfname" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("ccfname").style.background ='#e35152';
                // Show error prompt
                document.getElementById("ccfname" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
		  function validateccmName(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("ccmname").value)){
                // Style green
                document.getElementById("ccmname").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("ccmname" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("ccmname").style.background ='#e35152';
                // Show error prompt
                document.getElementById("ccmname" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
		  function validatecclName(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("cclname").value)){
                // Style green
                document.getElementById("cclname").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("cclname" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("cclname").style.background ='#e35152';
                // Show error prompt
                document.getElementById("cclname" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
		function validatehouseNo(){
            // Validation ruleuse
            var re = /[0-9]$/;
            // Check input
            if(re.test(document.getElementById("house").value)){
                // Style green
                document.getElementById("house").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("house" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("house").style.background ='#e35152';
                // Show error prompt
                document.getElementById("house" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatestreet(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("street").value)){
                // Style green
                document.getElementById("street").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("street" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("street").style.background ='#e35152';
                // Show error prompt
                document.getElementById("street" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatesubdivision(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("subdivision").value)){
                // Style green
                document.getElementById("subdivision").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("subdivision" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("subdivision").style.background ='#e35152';
                // Show error prompt
                document.getElementById("subdivision" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatecity(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("city").value)){
                // Style green
                document.getElementById("city").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("city" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("city").style.background ='#e35152';
                // Show error prompt
                document.getElementById("city" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatepostalCode(){
            // Validation rule
            var re = /[0-9]$/;
            // Check input
            if(re.test(document.getElementById("postalcode").value)){
                // Style green
                document.getElementById("postalcode").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("postalcode" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("postalcode").style.background ='#e35152';
                // Show error prompt
                document.getElementById("postalcode" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validateCountry(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("country").value)){
                // Style green
                document.getElementById("country").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("country" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("country").style.background ='#e35152';
                // Show error prompt
                document.getElementById("country" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
		function validatedhouseNo(){
            // Validation ruleuse
            var re = /[0-9]$/;
            // Check input
            if(re.test(document.getElementById("dhouse").value)){
                // Style green
                document.getElementById("dhouse").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("dhouse" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("dhouse").style.background ='#e35152';
                // Show error prompt
                document.getElementById("dhouse" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatedstreet(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("dstreet").value)){
                // Style green
                document.getElementById("dstreet").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("dstreet" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("dstreet").style.background ='#e35152';
                // Show error prompt
                document.getElementById("dstreet" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatedsubdivision(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("dsubdivision").value)){
                // Style green
                document.getElementById("dsubdivision").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("dsubdivision" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("dsubdivision").style.background ='#e35152';
                // Show error prompt
                document.getElementById("dsubdivision" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatedcity(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("dcity").value)){
                // Style green
                document.getElementById("dcity").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("dcity" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("dcity").style.background ='#e35152';
                // Show error prompt
                document.getElementById("dcity" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatedpostalCode(){
            // Validation rule
            var re = /[0-9]$/;
            // Check input
            if(re.test(document.getElementById("dpostalcode").value)){
                // Style green
                document.getElementById("dpostalcode").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("dpostalcode" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("dpostalcode").style.background ='#e35152';
                // Show error prompt
                document.getElementById("dpostalcode" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		function validatedCountry(){
            // Validation rule
            var re = /[A-Za-z -']$/;
            // Check input
            if(re.test(document.getElementById("dcountry").value)){
                // Style green
                document.getElementById("dcountry").style.background ='#ccffcc';
                // Hide error prompt
                document.getElementById("dcountry" + 'Error').style.display = "none";
                return true;
            }else{
                // Style red
                document.getElementById("dcountry").style.background ='#e35152';
                // Show error prompt
                document.getElementById("dcountry" + 'Error').style.display = "block";
				
                return false;   
            }
        }
		
        // Validate email
        function validateEmail(email){ 
            var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            if(re.test(email)){
                document.getElementById('email').style.background ='#ccffcc';
                document.getElementById('emailError').style.display = "none";
                return true;
            }else{
                document.getElementById('email').style.background ='#e35152';
                // Show error prompt
                document.getElementById("email" + 'Error').style.display = "block";
				
				return false;
            }
        }
        // Validate Select boxes
        function validateSelect(x){
            if(document.getElementById(x).selectedIndex !== 0){
                document.getElementById(x).style.background ='#ccffcc';
                document.getElementById(x + 'Error').style.display = "none";
                return true;
            }else{
                document.getElementById(x).style.background ='#e35152';
                return false;   
            }
        }
        function validateRadio(x){
            if(document.getElementById(x).checked){
                return true;
            }else{
                return false;
            }
        }
        function validateCheckbox(x){
            if(document.getElementById(x).checked){
                return true;
            }
            return false;
        }       
        function validateForm(){
            // Set error catcher
            var error = 0;
            // Check name
            if(!validateName('fname')){
                document.getElementById('fnameError').style.display = "block";
                error++;
            }
			if(!validatemName('mname')){
                document.getElementById('mnameError').style.display = "block";
                error++;
            }if(!validatelName('lname')){
                document.getElementById('lnameError').style.display = "block";
                error++;
            }if(!validateuserName('username')){
                document.getElementById('usernameError').style.display = "block";
                error++;
            }if(!validatepassword('password')){
                document.getElementById('passwordError').style.display = "block";
                error++;
            }if(!validatepassword('rpassword')){
                document.getElementById('rpasswordError').style.display = "block";
                error++;
            }if(!validatecardnumber('cardnumber')){
                document.getElementById('cardnumberError').style.display = "block";
                error++;
            }if(!validatecardholder('cardholdername')){
                document.getElementById('cardholdernameError').style.display = "block";
                error++;
            }if(!validatehouseNo('house')){
                document.getElementById('houseError').style.display = "block";
                error++;
            }if(!validatestreet('street')){
                document.getElementById('streetError').style.display = "block";
                error++;
            }if(!validatesubdivission('subdivision')){
                document.getElementById('subdivisionError').style.display = "block";
                error++;
            }if(!validatecity('city')){
                document.getElementById('cityError').style.display = "block";
                error++;
            }if(!validatepostalCode('postalcode')){
                document.getElementById('postalcodeError').style.display = "block";
                error++;
            }if(!validateCountry('country')){
                document.getElementById('countryError').style.display = "block";
                error++;
            }if(!validatedhouseNo('dhouse')){
                document.getElementById('dhouseError').style.display = "block";
                error++;
            }if(!validatedstreet('dstreet')){
                document.getElementById('dstreetError').style.display = "block";
                error++;
            }if(!validatedsubdivision('dsubdivision')){
                document.getElementById('dsubdivisionError').style.display = "block";
                error++;
            }if(!validatedcity('dcity')){
                document.getElementById('dcityError').style.display = "block";
                error++;
            }if(!validatedpostalCode('dpostalcode')){
                document.getElementById('dpostalcodeError').style.display = "block";
                error++;
            }if(!validatedCountry('dcountry')){
                document.getElementById('dcountryError').style.display = "block";
                error++;
            }
            // Validate email
            if(!validateEmail(document.getElementById('email').value)){
                document.getElementById('emailError').style.display = "block";
                error++;
            }
            // Validate animal dropdown box
            if(!validateSelect('animal')){
                document.getElementById('animalError').style.display = "block";
                error++;
            }
            // Validate Radio
            if(validateRadio('left')){
 
            }else if(validateRadio('right')){
                 
            }else{
                document.getElementById('handError').style.display = "block";
                error++;
            }
            if(!validateCheckbox('accept')){
                document.getElementById('termsError').style.display = "block";
                error++;
            }
            // Don't submit form if there are errors
            if(error > 0){
		
                return false;
            }
        }           
    